package com.cloud.provider.service.impl;

import com.cloud.provider.mapper.UserMapper;
import com.cloud.provider.pojo.SysUser;
import com.cloud.provider.service.ProviderDemoService;
import com.cloud.provider.util.ChineseName;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Random;

@Service
public class ProviderDemoServiceImpl implements ProviderDemoService {
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private ChineseName chineseName;


    @Override
    public String sayHello() {
        return "Hello World!";
    }

    @Override
    public void insertUser() {
        Random random = new Random();
        SysUser sysUser = new SysUser();
        for (int i = 1; i < 1000; i++) {
            sysUser.setId(i);
            sysUser.setUserName(chineseName.getName());
            sysUser.setSex(random.nextInt(2));
            sysUser.setAge(random.nextInt(99));
            System.out.println("sysUser = " + sysUser);
            userMapper.insert(sysUser);
        }
    }
}
